#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
int main()
{
  //umask(0);
  //int fd=open("bite.txt",O_CREAT|O_WRONLY|O_TRUNC,0666);
  struct stat st;
  int n = stat("bite.txt",&st);
  if(n<0)return 1;
  printf("file size:%lu\n",st.st_size);
  int fd=open("bite.txt",O_RDONLY);
  if(fd<0) return 2;
  char * file_buf=(char*)malloc(st.st_size+1);
  //const char*buf="i like linux!";
  //write(fd,buf,strlen(buf));
  n=read(fd,file_buf,st.st_size);
  if(n>0)
  {
    file_buf[n]='\0';
  }
  printf("%s\n",file_buf);
  free(file_buf);
  close(fd);
  return 0;
}
